package model.turtle;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
import util.Pixmap;

/**
 * Path.java contains information / method
 *      about the Commandable's path.
 *
 * @author Angelica Schwartz
 */
public class Path {
    
    /**
     * Contains the path segments for this path.
     */
    private List<PathSegment> pathSegments;

    /**
     * Constructor.
     */
    public Path() {
        pathSegments = new ArrayList<PathSegment>();
    }

    /**
     * adds a new line segment.
     * @param p1
     * @param p2
     * @param c
     * @param width
     * @param design
     * @param down
     */
    public void addNewSegment(Point2D p1, Point2D p2,
                              Color c, int width, String design, boolean down) {
        pathSegments.add(new LineSegment(p1, p2, c, width, design, down));
    }

    /**
     * adds a new stamp segment.
     * @param image
     * @param size
     * @param start
     * @param angle
     */
    public void addNewSegment(Pixmap image, Dimension size,
                              Point2D.Double start, double angle) {
        pathSegments.add(new StampSegment(image, size, start, angle));
    }

    /**
     * paints the whole path.
     */
    public void paint(Graphics pen) {
        for (PathSegment segment : pathSegments) {
            segment.paint((Graphics2D) pen);
        }
    }
    
    /**
     * clears the stamp segments.
     */
    public void clearStamps() {
        for (int i = 0; i < pathSegments.size(); i++) {
            if (pathSegments.get(i) instanceof StampSegment) {
                pathSegments.remove(i);
                i--;
            }
        }
    }
    
    public void clearPath() {
        pathSegments.clear();
    }
}
